package duoqiao;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class A4 {
    //从文件中读取 字节转字符  FileInputStream
    public static void main(String[] args) throws IOException {
//        FileInputStream fis = new FileInputStream("ko.txt");
//        byte[] data = new byte[1024];//读取字节
//        int len = fis.read(data);//len实际读取到的字节数
//        System.out.println("读取到了"+len+"个字节");
//        String line = new String(data, 0,len,StandardCharsets.UTF_8);//字节转字符
////         public String(byte bytes[], int offset, int length, Charset charset)
//        System.out.println(line);
//        fis.close();

        FileInputStream fis = new FileInputStream("ll.dat");
        byte[] data = new byte[1024];
        int len = fis.read(data);
        System.out.println(len+"个字节");
        String line = new String(data,0,len,StandardCharsets.UTF_8);
        System.out.println(line);
    }
}
